<template>
	<view>
		<view class="module-block" v-if="cfg_write_tourer ==1">
			<view class="module-info">
				<view class="module-title">旅客信息</view>
				<view class="traveller-group">
					<view class="traveller-subs">请务必保证填写项与出游所持证件一致</view>
					<view class="traveller-select">
						<block v-for="(item,index) in tourerList" :key="index">
							<view class="label" :class="{on:item.active}" @click="selectTouer(item)" v-if="index < 2">{{item.linkman}}</view>
						</block>
						<view class="more" @click="jumpTraveller">选择出行旅客<text class="iconfont">&#xe67f;</text></view>
					</view>
					<view class="traveller-list">
						<block v-for="(item,index) in tourerList" :key="index">
							<block v-if="item.active">
								<view class="traveller-item" v-if="!memberCardId" @click="editTourer(item)">
									<view class="name">{{item.linkman}}</view>
									<view class="number">{{item.cardtype}}{{item.idcard}}</view>
									<view class="iconfont">&#xe67f;</view>
								</view>
								<view class="traveller-item" v-else>
									<view class="name">{{item.linkman}}</view>
									<view class="number">{{item.cardtype}}{{item.idcard}}</view>
								</view>
							</block>
						</block>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	/**
	 * 旅客信息
	 * 
	 */
	export default {
		name: 'stTravellerInfo',
		props:{
			cfg_write_tourer:{
				type: String,
				default: '0'
			},
			memberCardId:{
				type: String,
				default: ''
			},
			isRealName:{
				type: String,
				default: '0'
			},
			tourerList:{
				type: Array,
				default (){
					return []
				}
			},
			amount: {
				type: Number,
				default:0
			}
		},
		data() {
			return {
				
			};
		},
		mounted() {
			
		},
		methods: {
						// 选择游客
			selectTouer(item){
				this.$emit('selectTouer',item);
			},
			// 跳转旅客选择页面
			jumpTraveller(){
				let tourerArr = [];
				// 获取已选择的游客数据
				this.tourerList.map(item=> {
					if(item.active)
					{
						tourerArr.push(item.id);
					}
				})
				let tourerid = tourerArr.join(',');
				let amount = this.amount;
				let url= '../../subPackages/guest/select?tourerid='+tourerid+'&amount='+amount
				if(this.memberCardId){
					url += '&member_card_id='+this.memberCardId+'&isRealName='+this.isRealName
				}
				uni.navigateTo({
					url: url
				})
			},
			// 跳转游客编辑页面
			editTourer(item){
				uni.navigateTo({
					url:`../../subPackages/guest/edit?item=${encodeURIComponent(JSON.stringify(item))}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.module-block{
		padding: 0 24rpx;
		margin-bottom: 20rpx;
		.module-info{
			padding: 28rpx 24rpx;
			border-radius: 20rpx;
			background-color: $uni-bg-color;
			.module-title{
				line-height: 1.24;
				font-size: 34rpx;
				font-weight: bold;
			}
			.traveller-group{
				margin-top: 28rpx;
				.traveller-subs{
					line-height: 2.67;
					padding: 0 20rpx;
					font-size: $uni-font-size-sm;
					color: #ff4a50;
					border-radius: 10rpx;
					background-color: #ffefec;
					.iconfont{
						margin: 0 10rpx 0 6rpx;
						color: $uni-text-color-price;
					}
				}
				.traveller-select{
					@extend .displayflex;
					flex-wrap:wrap;
					padding: 20rpx 0 4rpx;
					.label,.more{
						@extend .alignJustify;
						height: 61rpx;
						min-width: 130rpx;
						margin: 0 18rpx 20rpx 0;
						padding: 0 16rpx;
						border-radius: 10rpx;
						border: 2rpx solid #e5e5e5;
						font-size: $uni-font-size-base;
						&.on{
							background-color: $uni-bg-color-primary;
							color: $uni-text-color-inverse;
							border-color: $uni-color-primary;
						}
					}
					.more{
						.iconfont{
							position: relative;
							top: 2rpx;
							color: #a0a0a0;
						}
					}
				}
			}
			.traveller-list{
				.traveller-item{
					position: relative;
					padding: 16rpx 0;
					.name{
						font-size: $uni-font-size-base;
						line-height: 1.57;
					}
					.number{
						font-size: $uni-font-size-sm;
						color: $uni-text-color-grey;
						line-height: 1.83;
					}
					.iconfont{
						position: absolute;
						right: 0;
						top: 50%;
						transform: translateY(-50%);
						color: #a0a0a0;
					}
				}
			}
		}
	}
</style>
